﻿using BCT.Domains;
using BCT.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Claims;
using System.Web.Http;

namespace BCT.Api.Controllers
{
    [Authorize]
    public class UserController : ApiController
    {
        private readonly IUserDomain _userDomain;

        public UserController(UserDomain userDomain)
        {
            _userDomain = userDomain;
        }
        public Response GetUserInfo()
        {
            //var id = int.Parse(((ClaimsIdentity)User.Identity).Claims
            //    .Where(_ => _.Type == "Id").First().Value);
            var id = int.Parse(User.Identity.Name);
            var userinfo =  _userDomain.GetUserInfo(id);
            return new Response() { data = userinfo };
        }
    }
}
